package com.example.bigdata.task;

import java.util.Map;
import java.util.Timer;
import java.util.TimerTask;

/**
 * @author jie
 * @date 2021/5/26 -16:55
 */
public class MyTask extends TimerTask {

    private String id;
    private Timer timer;
    private int[] aa;
    private int pos = 0;
    private boolean removeFlag;
    private Map<String, Timer> map;


    public MyTask(Timer timer, String id, int[] aa, Map<String, Timer> map,int pos) {
        this.id = id;
        this.timer = timer;
        this.aa = aa;
        this.pos = pos;
        this.map = map;
    }

    public MyTask(String id, Map<String, Timer> map,boolean removeFlag,int delay) {
        this.id = id;
        this.map = map;
        this.removeFlag = removeFlag;
        this.pos = delay;
    }

    public MyTask() {
    }

    @Override
    public void run() {
        System.out.println("推送微信消息"+pos);
        if (removeFlag){
            map.remove(this.id);
            System.out.println("消息完毕");
        }

      /*  System.out.println("start==" + id);

        // todo 查指定pos时间员工 并且是组
        // todo 推送微信消息
        System.out.println("推送微信消息");
        this.pos++;

        if (this.pos < aa.length) {
            timer.schedule(new MyTask(timer,id,aa,map,pos), (this.aa[pos] - this.aa[pos - 1] )* 1000);

        } else {
            timer.cancel();
            map.remove(this.id);
            System.out.println("消息完毕");
        }*/
    }
}
